import {Context} from 'koa';
import {koaBody} from 'koa-body';
import Router from 'koa-router';
import {resolve} from 'path';
import {CWD_PATH} from '@/config';
import ImageController from '@/controller/ImageController';
const router = new Router();

router.get('/ping', (ctx: Context) => ctx.body = 'pong');
router.post('/compressImg', koaBody({
    multipart: true,
    formidable: {
        allowEmptyFiles: false,
        uploadDir: resolve(CWD_PATH, './public/tmp'),
        keepExtensions: true
    }
}), ImageController.compressImg);


export default router;
